package com.example.demo.controller;

import com.example.demo.Interface.DataRepo;
import com.example.demo.entity.Data;
import com.example.demo.entity.Shidu;
import com.example.demo.entity.Wendu;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Controller
public class Getshidu {
    @Resource
    DataRepo dataRepo;

    @RequestMapping(value="/getShidu")
    @ResponseBody
    public List<Shidu> getshidu(){
        List<Shidu> list = new ArrayList<Shidu>();//温度对象list
        List<Data> optionalData  = dataRepo.findAll();//查询所有数据
        for(Data data:optionalData){
            String time1 = new String(data.time);
            String shidu1 = new String(data.shidu);
            list.add(new Shidu(time1,shidu1));
        }

        System.err.println(list.toString());
        return list;
    }

    @RequestMapping(value="/shidus")
    public String get(){
        return "shidu";
    }

}
